
import Vue from 'vue';
import Vuex from 'vuex'

Vue.use(Vuex);

const store = new Vuex.Store({
  state: {
    acount: 10,
    userInfo: {
      myshop: {
        id: '1251400',
        name: '天天好礼店铺',
      },
      userImage: 'https://ss1.bdstatic.com/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=2584128192,4095037283&fm=111&gp=0.jpg',
      userName: 'mapbar_front',
      tellPhone: 15910590943
    }
  },
  mutations:{
    checkout: function(state,pay){
     // state.acount -= pay
    },
    changShopName: function(state, name){
      // state.userInfo.myshop.name = name
    },
    changeAcount:function(state){
      state.acount++;
    },
    changeAcount2:function(state,value){
      state.acount=value;
    }
  },
  getters:{
         //z这里是得到值计算出来的值，请不会改变acount的值
       myGetters:function (state) {
          return state.acount*3
       }
  },
   //调用这里的actions里面的方法去改变 state: {}里面的值得话 只能是去触发mutations里面放去触发
    //外面的组件怎么去触发actions myactions的myactions
    //这是三连反应有点绕。
  actions:{
      myactions:function(context){

            context.commit("changeAcount");
      }
  }
});

export default store;

